namespace Microsoft.VisualStudio.EnterpriseTools.OperationDesigner
{
    using Microsoft.VisualStudio.VirtualTreeGrid;
    using System;

    public sealed class VariableColumnTree : VirtualTree, IMultiColumnTree
    {
        private int myColumns;
        private ITree mySingleColumnTree;

        public VariableColumnTree(int columns)
        {
            base.EnableMultiColumn();
            this.myColumns = columns;
        }

        public void ChangeColumnCount(int newColumnCount)
        {
            this.myColumns = newColumnCount;
        }

        void IMultiColumnTree.UpdateCellStyle(IBranch branch, int row, int column, bool makeComplex)
        {
            base.UpdateCellStyle(branch, row, column, makeComplex);
        }

        protected sealed override int ColumnCount
        {
            get
            {
                return this.myColumns;
            }
        }

        int IMultiColumnTree.ColumnCount
        {
            get
            {
                return this.myColumns;
            }
        }

        ITree IMultiColumnTree.SingleColumnTree
        {
            get
            {
                return this.SingleColumnTree;
            }
        }

        protected sealed override ITree SingleColumnTree
        {
            get
            {
                if (this.mySingleColumnTree == null)
                {
                    this.mySingleColumnTree = base.CreateSingleColumnTree();
                }
                return this.mySingleColumnTree;
            }
        }
    }
}

